package com.zj.leetcode.easy.greed;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: algorithm
 * @description:
 * 分发饼干
 * 455 assign-cookies
 * @author: Zhang Bo
 * @create: 2022-01-14 17:05
 **/
public class AssignCookies{
    public static void main(String[] args) {
        Solution solution = new AssignCookies().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int findContentChildren(int[] g, int[] s) {

            Arrays.sort(s);
            List<Integer> ns = Arrays.stream(s).boxed().collect(Collectors.toList());
            int count = 0;
            for (int i = 0; i < g.length; i++) {
                for (int j = 0; j < ns.size(); j++) {
                    if(ns.get(j) >= g[i]){
                        count++;
                        ns.remove(j);
                        break;
                    }
                }
            }
            return count;

        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
